﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chinesys.Entities;
using Chinesys.DataModel;

namespace Chinesys.Domain.DataMapper
{
    public static class UserDataMapper
    {
        public static UserEntity UserFromRowToeEntity(UserApp row)
        {
            UserEntity entity;
            if (row != null)
            {
                entity = new UserEntity();

                entity.Address = row.Address;
                entity.Email = row.Email;
                entity.FirstName = row.FirstName;
                entity.Id = row.Id;
                entity.LastName = row.LastName;
                entity.Newsletter = row.Newsletter;
                entity.Pass = row.Pass;
                entity.PhoneOne = row.PhoneOne;
                entity.PhoneThree = row.PhoneThree;
                entity.PhoneTwo = row.PhoneTwo;
                entity.UserName = row.UserName;
                entity.Active = row.Active;
                entity.CurrentState = RowState.Original;
            }
            else
                entity = null;

            return entity;
        }

        public static UserApp UserFromEntityToRow(UserEntity entity)
        {
            UserApp row;

            if (entity != null)
            {
                row = new UserApp();

                row.Address = entity.Address;
                row.Email = entity.Email;
                row.FirstName = entity.FirstName;
                row.Id = entity.Id;
                row.LastName = entity.LastName;
                row.Newsletter = entity.Newsletter;
                row.Pass = entity.Pass;
                row.PhoneOne = entity.PhoneOne;
                row.PhoneThree = entity.PhoneThree;
                row.PhoneTwo = entity.PhoneTwo;
                row.UserName = entity.UserName;
                row.Active = entity.Active;
            }
            else
                row = null;

            return row;
        }
    }
}
